﻿Public Class UserBE : Inherits PersonBE
#Region "<< -Attributes- >>"
    Private _UserName As String = String.Empty
    Private _Password As String = String.Empty
    Private _Profile As ProfileBE = Nothing
    Private _Question As QuestionBE = Nothing
    Private _Answer As String = String.Empty
    Private _Blocked As Boolean? = Nothing
    Private _BlockStarted As Date? = Nothing
#End Region

#Region "<< -Properties- >>"

#Region "[UserName]"
    Public Property UserName As String
        Get
            Return _UserName
        End Get
        Set(value As String)
            _UserName = value
        End Set
    End Property
#End Region

#Region "[Password]"
    Public Property Password As String
        Get
            Return _Password
        End Get
        Set(value As String)
            _Password = value
        End Set
    End Property
#End Region

#Region "[Profile]"
    Public Property Profile As ProfileBE
        Get
            Return _Profile
        End Get
        Set(value As ProfileBE)
            _Profile = value
        End Set
    End Property
#End Region

#Region "[Question]"
    Public Property Question As QuestionBE
        Get
            Return _Question
        End Get
        Set(value As QuestionBE)
            _Question = value
        End Set
    End Property
#End Region

#Region "[Answer]"
    Public Property Answer As String
        Get
            Return _Answer
        End Get
        Set(value As String)
            _Answer = value
        End Set
    End Property
#End Region

#Region "[Blocked]"
    Public Property Blocked As Boolean?
        Get
            Return _Blocked
        End Get
        Set(value As Boolean?)
            _Blocked = value
        End Set
    End Property
#End Region

#Region "[BlockStarted]"
    Public Property BlockStarted As Date?
        Get
            Return _BlockStarted
        End Get
        Set(value As Date?)
            _BlockStarted = value
        End Set
    End Property
#End Region

#End Region

#Region "<< -Methods- >>"
    ''' <summary>
    ''' Devuelve la constraseña del usuario encriptada en base 64
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function EncryptPassword(pRawPassword As String) As String
        Try
            Dim wBuffer As Byte() = System.Text.Encoding.UTF8.GetBytes(pRawPassword)
            Return Convert.ToBase64String(wBuffer)
        Catch ex As Exception
            Throw ex
        End Try
    End Function

    ''' <summary>
    ''' Desencripta el contraseña del usuario
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function DecryptPassword() As String
        Try
            Dim wBuffer As Byte() = Convert.FromBase64String(_Password)
            Return System.Text.Encoding.UTF8.GetString(wBuffer)
        Catch ex As Exception
            Throw ex
        End Try
    End Function
#End Region

End Class
